/*
** 本地缓存登录用户数据
** 为登录提示提供数据
*/

export default (ctx, next) =>{

    let { store, params:userInfo }  = ctx;
    let data = {

        [userInfo.phone]: {
            signTime: new Date(),
            username: userInfo.nickname
        }
        
    }

    store.dispatch('localStore/has', data).then(has =>{

        let key = has ? 'updateAccounts' : 'addAccounts';
        store.dispatch(`localStore/${key}`, data)
        
    })

    next()
}